package com.itheima.exer.homework.hw1011.system1;

public class Foodie implements Runnable{

    @Override
    public void run() {
        synchronized (Desk.object) {
            while (true) {
                if (Desk.count == 0){
                    break;
                }else {
                    if (Desk.flag){
                        System.out.println("吃货在吃东西!!!");
                        Desk.count--;
                        Desk.flag = false;
                        Desk.object.notifyAll();
                    }else {
                        try {
                            Desk.object.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    }
}
